package com.dalongxin.work.data;

import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.table.DatabaseTable;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

/**
 * Created by 赵宇 on 2017/10/26.
 * 网盘上传的文件
 */
@DatabaseTable(tableName="cloud_disk_upload_file")
public class CloudDiskUploadFile {

    @DatabaseField(id = true)
    private String fileMD5; //文件的MD5值

    @DatabaseField
    private String fileId; //上传接口中用到的id

    @DatabaseField
    private int fileUploadedPiece; //已上传的片数

    @DatabaseField
    private int totalPiece; //总片数

    @DatabaseField
    private long fileLength; //文件大小

    @DatabaseField
    private String fileName; //文件名

    @DatabaseField
    private String uploadTime; //上传时间

    @DatabaseField
    private long uploadBeganPlace; //上传文件开始点 单位精确到字节(b)

    public CloudDiskUploadFile() {
    }

    public CloudDiskUploadFile(String fileMD5, String fileId, int fileUploadedPiece, int totalPiece, long fileLength, String fileName) {
        this.fileMD5 = fileMD5;
        this.fileId = fileId;
        this.fileUploadedPiece = fileUploadedPiece;
        this.totalPiece = totalPiece;
        this.fileLength = fileLength;
        this.fileName = fileName;
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA);
        this.uploadTime = sdf.format(new Date());
    }

    public String getFileMD5() {
        return fileMD5;
    }

    public void setFileMD5(String fileMD5) {
        this.fileMD5 = fileMD5;
    }

    public String getFileId() {
        return fileId;
    }

    public void setFileId(String fileId) {
        this.fileId = fileId;
    }

    public int getFileUploadedPiece() {
        return fileUploadedPiece;
    }

    public void setFileUploadedPiece(int fileUploadedPiece) {
        this.fileUploadedPiece = fileUploadedPiece;
    }

    public long getFileLength() {
        return fileLength;
    }

    public void setFileLength(long fileLength) {
        this.fileLength = fileLength;
    }

    public int getTotalPiece() {
        return totalPiece;
    }

    public void setTotalPiece(int totalPiece) {
        this.totalPiece = totalPiece;
    }

    public void pieceIncrease() {
        fileUploadedPiece++;
    }

    public long getUploadBeganPlace() {
        return uploadBeganPlace;
    }

    public void setUploadBeganPlace(long uploadBeganPlace) {
        this.uploadBeganPlace = uploadBeganPlace;
    }

    @Override
    public String toString() {
        return "CloudDiskUploadFile{" + "fileMD5='" + fileMD5 + '\'' + ", fileId='" + fileId + '\'' + ", fileUploadedPiece=" + fileUploadedPiece + ", totalPiece=" + totalPiece + ", fileLength=" + fileLength + ", fileName='" + fileName + '\'' + ", uploadTime='" + uploadTime + '\'' + ", uploadBeganPlace=" + uploadBeganPlace + '}';
    }
}
